<?php
/**
 * Created by PhpStorm.
 * User: yangxin
 * Date: 02/01/2017
 * Time: 13:27
 */

namespace app\admin\controller;


use app\common\controller\BaseController;
use think\Request;

class AdminBaseController extends BaseController
{

    protected function _initialize()
    {
        parent::_initialize();
        if (strpos(Request::instance()->path(),"/sysuser/login") ||
            strpos(Request::instance()->path(),"/sysuser/doLogin")) {
            return;
        }

        if (!$this->isLogin()) {
            $this->redirect('/admin/sysuser/login');
        }

        // 判断是否锁屏
        $user = $this->getLoginUser();
        if (isset($user['lock']) && $user['lock'] === true) {
            if (strpos(Request::instance()->path(),"/sysuser/lockscreen") ||
                strpos(Request::instance()->path(),"/sysuser/unlockscreen")) {
                return;
            }
            $this->redirect('/admin/sysuser/lockscreen');
        }
    }

}